'''
Created on 11/01/2014

@author: Jesus Gomez
'''
import urllib2
import process_html

f = open("ids_clean.txt",'r')
out = open('recipes.txt','w+')

i = 0
line = f.readline()

url_prefix = "http://www.recetas.net/receta.asp?ID="

while line:
    
    url = url_prefix+line
    usock = urllib2.urlopen(url);
    data = usock.read()
    
    i+=1
    
    process_html.process_html(data,out)
    
    print("procesando receta",i,"de 6897. Progreso total: ",(i/6879)*100,"%")
    
    line = f.readline()
    usock.close()
    
out.close()
f.close()